package java_demos.java_io.create_file;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

public class CreateFileJava7 {
    public static void main(String[] args) {
        // 在java7中使用 Files.write
        // 创建文件路径
        String filePath = "create_file_java7.txt";
        // 创建文件内容
        String content = "This is a file created by java7 Files.wtite() method.";
        // 写入文件
        try {
            Files.write(Paths.get(filePath), content.getBytes(StandardCharsets.UTF_8));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
